package logic

import (
	"context"
	"strconv"
	"week1_zg6/common/pay"
	"week1_zg6/orderrpc/internal/svc"
	"week1_zg6/orderrpc/order"

	"github.com/zeromicro/go-zero/core/logx"
)

type PayLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewPayLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PayLogic {
	return &PayLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *PayLogic) Pay(in *order.PayRequest) (*order.PayResponse, error) {
	s := pay.Pay(in.Amount, strconv.FormatInt(in.OrderID, 10))
	return &order.PayResponse{
		Data: s,
	}, nil
}
